In babl_palette_set_palette(), fall back to the default palette,
and log a warning, when trying to create a palette with < 1 colors.
BablPalette *pal = NULL;
int bpp = babl_format_get_bytes_per_pixel (format);
+ babl_assert (count > 0);
+
pal = babl_malloc (sizeof (BablPalette));
pal->count = count;
pal->format = format;
{
BablPalette **palptr = babl_get_user_data (babl);
babl_palette_reset (babl);
- *palptr = make_pal (format, data, count);
+ if (count > 0)
+ {
+ *palptr = make_pal (format, data, count);
+ }
+ else
+ {
+ babl_log ("attempt to create a palette with %d colors. "
+ "using default palette instead.",
+ count);
+ }
}
void